<?php
define('ipos',true);
require('../include/config.php');
require('./function.php');

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Phần quản lý dành cho quản trị viên</title>
</head>
<body>
<?php
$levelTL	=	$_SESSION['groupid'];
if($_SESSION['adminid']) {
	if($_GET['logout']==1) {
		$_SESSION['adminid']	=	"";
		$_SESSION['groupid']	=	"";
		header("location: index.php");	
	}
	?>
	<link rel="stylesheet" href="./css/styles.css" type="text/css" />
	<link rel="stylesheet" href="./css/menu_styles.css" type="text/css" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
	<script type="text/javascript" src="./js/admin.js"></script>
    <script type="text/javascript" src="./js/check.js"></script>
<div id="main_wrapper">
	<div class="right_shadow"><div></div></div>
<div class="header">
	<div class="cell">
		<div id="width"></div>
		<div class="logos" id="logos">
			<!--<span class="slogan">E-mail Components &amp; Applications<br />Supported with Professional Services</span>-->
			<div class="menu">
<ul>
<?php
if($levelTL == 3) {
?>
	<li><a class="l1 l1_f" href="index.php?ipos=category"><span class="link_text"><span class="top_corner">Thể loại</span></span><!--[if gte IE 7]><!--></a><!--<![endif]-->
		<table border="0" class="dd" cellpadding="0" cellspacing="0"><tr><td>
			<span class="shadow0"></span>
			<span class="shadow1">
				<span class="shadow2">
					<span class="shadow3">
						<span class="b">&nbsp;</span>
						<span class="content">
							<a class="l2 nogroup" href="index.php?ipos=category">Danh sách thể loại</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=category&mode=add">Thêm mới thể loại</a>
						</span>
						<span class="b">&nbsp;</span>
					</span>
				</span>
			</span>
		</td></tr></table>
	<!--[if lte IE 6]></a><![endif]-->
	</li>
	<li><a class="l1" href="index.php?ipos=country"><span class="link_text"><span class="top_corner">Quốc Gia</span></span><!--[if gte IE 7]><!--></a><!--<![endif]-->
		<table border="0" class="dd" cellpadding="0" cellspacing="0"><tr><td>
			<span class="shadow0"></span>
			<span class="shadow1">
				<span class="shadow2">
					<span class="shadow3">
						<span class="b">&nbsp;</span>
						<span class="content">
							<a class="l2 nogroup" href="index.php?ipos=country">Danh sách quốc gia</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=country&mode=add">Thêm mới quốc gia</a>
						</span>
						<span class="b">&nbsp;</span>
					</span>
				</span>
			</span>
		</td></tr></table>
	<!--[if lte IE 6]></a><![endif]-->
	</li>
	<li><a class="l1" href="index.php?ipos=user"><span class="link_text"><span class="top_corner">User</span></span><!--[if gte IE 7]><!--></a><!--<![endif]-->
	<!--[if lte IE 6]></a><![endif]-->
	</li>
	<li><a class="l1" href="index.php?ipos=film"><span class="link_text"><span class="top_corner">Phim</span></span><!--[if gte IE 7]><!--></a><!--<![endif]-->
		<table border="0" class="dd" cellpadding="0" cellspacing="0"><tr><td>
			<span class="shadow0"></span>
			<span class="shadow1">
				<span class="shadow2">
					<span class="shadow3">
						<span class="b">&nbsp;</span>
						<span class="content">
							<a class="l2 nogroup" href="index.php?ipos=addfilm">Thêm mới tập phim</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=clipvn">Grab link phim</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=phimle">Danh sách phim lẻ</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=phimbo1">Danh sách phim bộ đã hoàn thành</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=phimbo2">Danh sách phim bộ chưa hoàn thành</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=hot">Danh sách phim HOT</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=decu">Danh sách phim đề cử</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=chieurap">Danh sách phim chiếu rạp</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=error">Danh sách phim bị lỗi</a>
						</span>
						<span class="b">&nbsp;</span>
					</span>
				</span>
			</span>
		</td></tr></table>
	<!--[if lte IE 6]></a><![endif]-->
	</li>
	<li><a class="l1 l1_f" href="index.php?ipos=adv"><span class="link_text"><span class="top_corner">Quảng Cáo</span></span><!--[if gte IE 7]><!--></a><!--<![endif]-->
		<table border="0" class="dd" cellpadding="0" cellspacing="0"><tr><td>
			<span class="shadow0"></span>
			<span class="shadow1">
				<span class="shadow2">
					<span class="shadow3">
						<span class="b">&nbsp;</span>
						<span class="content">
							<a class="l2 nogroup" href="index.php?ipos=adv&mode=add">Thêm quảng cáo</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=adv">Danh sách quảng cáo</a>
						</span>
						<span class="b">&nbsp;</span>
					</span>
				</span>
			</span>
		</td></tr></table>
	<!--[if lte IE 6]></a><![endif]-->
	</li>
	<li><a class="l1 l1_f" href="index.php?ipos=pages"><span class="link_text"><span class="top_corner">Tạo trang</span></span><!--[if gte IE 7]><!--></a><!--<![endif]-->
		<table border="0" class="dd" cellpadding="0" cellspacing="0"><tr><td>
			<span class="shadow0"></span>
			<span class="shadow1">
				<span class="shadow2">
					<span class="shadow3">
						<span class="b">&nbsp;</span>
						<span class="content">
							<a class="l2 nogroup" href="index.php?ipos=pages&mode=add">Thêm trang</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=pages">Danh sách trang</a>
						</span>
						<span class="b">&nbsp;</span>
					</span>
				</span>
			</span>
		</td></tr></table>
	<!--[if lte IE 6]></a><![endif]-->
	</li>
	<li><a class="l1 l1_l" href="#"><span class="link_text"><span class="top_corner">Khác</span></span><!--[if gte IE 7]><!--></a><!--<![endif]-->
		<table border="0" class="dd" cellpadding="0" cellspacing="0"><tr><td>
			<span class="shadow0"></span>
			<span class="shadow1">
				<span class="shadow2">
					<span class="shadow3">
						<span class="b">&nbsp;</span>
						<span class="content">
							<a href="index.php?ipos=server" class="l2 nogroup">Server phim</a>
							<span class="line">&nbsp;</span>
							<a href="index.php?ipos=cf&ipid=1" class="l2 nogroup">Footer</a>
							<span class="line">&nbsp;</span>
                            <a href="index.php?ipos=cf&ipid=2" class="l2 nogroup">Thông báo</a>
							<span class="line">&nbsp;</span>
                            <a href="index.php?ipos=cf&ipid=3" class="l2 nogroup">Text Link</a>
							<span class="line">&nbsp;</span>
                            <a href="index.php?ipos=cf&ipid=4" class="l2 nogroup">Tags</a>
							<span class="line">&nbsp;</span>
                            <a href="index.php?ipos=comment" class="l2 nogroup">Bình luận phim</a>
							<span class="line">&nbsp;</span>
                            <a href="index.php?ipos=request" class="l2 nogroup">Yêu cầu</a>
							<span class="line">&nbsp;</span>
                            <a href="index.php?logout=1" class="l2 nogroup">Đăng xuất</a>
						</span>
						<span class="b">&nbsp;</span>
					</span>
				</span>
			</span>
		</td></tr></table>
	<!--[if lte IE 6]></a><![endif]-->
	</li>
<?php } else { ?>

<li><a class="l1 l1_f" href="index.php?ipos=addfilm"><span class="link_text"><span class="top_corner">Thêm phim mới</span></span></a></li>
<li><a class="l1 l1_f" href="index.php?ipos=film"><span class="link_text"><span class="top_corner">Danh sách phim</span></span>
<!--[if gte IE 7]><!--></a><!--<![endif]-->
		<table border="0" class="dd" cellpadding="0" cellspacing="0"><tr><td>
			<span class="shadow0"></span>
			<span class="shadow1">
				<span class="shadow2">
					<span class="shadow3">
						<span class="b">&nbsp;</span>
						<span class="content">
							<a class="l2 nogroup" href="index.php?ipos=film&mode=phimle">Danh sách phim lẻ</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=phimbo1">Danh sách phim bộ đã hoàn thành</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=phimbo2">Danh sách phim bộ chưa hoàn thành</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=hot">Danh sách phim HOT</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=decu">Danh sách phim đề cử</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=chieurap">Danh sách phim chiếu rạp</a>
							<span class="line">&nbsp;</span>
							<a class="l2 nogroup" href="index.php?ipos=film&mode=error">Danh sách phim bị lỗi</a>
						</span>
						<span class="b">&nbsp;</span>
					</span>
				</span>
			</span>
		</td></tr></table>
	<!--[if lte IE 6]></a><![endif]-->
</li>
<li><a class="l1 l1_l" href="index.php?logout=1"><span class="link_text"><span class="top_corner">Đăng xuất</span></span></a>
<?php } ?>
</ul>
</div>

		</div>
		<div class="b"></div>
	</div>
</div>
	<div class="main_block">
		<div class="cell">
			<div id="content_panel">
<?php
$ipos	=	$_GET['ipos'];
$mode	=	$_GET['mode'];
$ipid	=	$_GET['ipid'];
$page	=	$_GET['p'];
switch($ipos){
	case "category":		require_once("./code/category.php");break;
	case "country":			require_once("./code/country.php");break;
	case "film":			require_once("./code/film.php");break;
	case "epfilm":			require_once("./code/epfilm.php");break;
	case "addfilm":			require_once("./code/php/addfilm.php");break;
	case "adv":				require_once("./code/adv.php");break;
	case "cf":				require_once("./code/php/config.php");break;
	case "comment":			require_once("./code/comment.php");break;
	case "request":			require_once("./code/request.php");break;
	case "pages":			require_once("./code/pages.php");break;
	case "server":			require_once("./code/server.php");break;
	case "user":			require_once("./code/user.php");break;
	case "clipvn":			require_once("./code/php/clipvn.php");break;
	default :				require_once("./code/home.php");break;
}
?>
			</div>
			<div class="clear"></div>
		</div>
	</div>
</div>
<div id="footer" class="footer">
	<div class="right_shadow"></div>
	<div class="cell">
		
		<div class="copy">
			
			
			<div class="content">
				<span class="copyright">&copy; Copyright 2012 PHIMBMT. Xem tốt nhất với Firefox & Google Chrome.
				</span>
				<div class="clear"></div>
			</div>
		</div>
		<div class="b bottom"></div>
		<div class="a bottom"></div>
	</div>
</div>
<?php
}else {
	if($_POST['submit']) {
		$name 		= isset($_POST["aduser"]) ? htmlspecialchars($_POST["aduser"]) : '';
		$pass 		= isset($_POST["adpass"]) ? htmlspecialchars($_POST["adpass"]) : '';
		$arr 		= $db->database(" userid, usergroup, password, usercode ","user"," username = '".$name."' AND usergroup IN (2,3)");
		$pass_new 	= md5(md5($pass).$arr[0][3]);
		if($arr[0][2] == $pass_new) {
			$_SESSION['adminid']	=	$arr[0][0];
			$_SESSION['groupid']	=	$arr[0][1];
			header("location: index.php");
		}
	}
?>
<link rel="stylesheet" href="./css/login.css" type="text/css" />
	<div id="content" class="wm_content">

<div class="wm_content">
	<div id="login_screen" class="wm_login">
		<form name="login" method="post">
						<div class="wm_login">
				<div class="a top"></div>
				<div class="b top"></div>
				<div class="login_table" style="margin: 0px;">
					<div class="wm_login_header">Đăng nhập Cpanel</div>
					<div class="wm_login_content">

						<table id="login_table" border="0" cellspacing="0" cellpadding="10">
						<tr>
							<td class="wm_title" style="font-size: 12px; width: 70px">Username:</td>
							<td>
								<input class="wm_input" size="20" type="text" id="aduser" name="aduser"
									style="width: 99%; font-size: 16px;" onfocus="this.style.background = '#FFF9B2';"
									onblur="this.style.background = 'white';" value=""
								/>
							</td>
						</tr>
						<tr>

							<td class="wm_title" style="font-size: 12px; width: 70px">Password:</td>
							<td>
								<input class="wm_input" type="password" size="20" id="aduser" name="adpass"
									style="width: 99%; font-size: 16px;" onfocus="this.style.background = '#FFF9B2';"
									onblur="this.style.background = 'white';" value=""
								/>
							</td>
						</tr>
						<tr>
							<td align="right" colspan="2">
								<span class="wm_login_button">

									<input class="wm_button" type="submit" name="submit" value="Đăng nhập" />
								</span>
							</td>
						</tr>
					</table>
					</div>
				</div>
				<div class="b"></div>
				<div class="a"></div>

			</div>
			<div class="info" id="demo_info" dir="ltr">
<div class="demo_note">
Đây là trang dành cho người quản lý website. <br />Nếu bạn không phải người quản lý website vui lòng click <a href="..">vào đây</a>.
</div>
</div>		</form>
	</div>
</div>	</div>
<? } ?>
</body>
</html>